//
//  ViewController.m
//  WH_GCD
//
//  Created by mafeng on 16/8/18.
//  Copyright © 2016年 mafeng. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    [self createSerialQueue];
    [self createConcurent];
    
    
    
}

- (void)createSerialQueue {
    dispatch_queue_t serial = dispatch_queue_create("tech.mafeng", DISPATCH_QUEUE_SERIAL);
    NSLog(@"%@", [NSThread currentThread]);
    
    dispatch_async(serial, ^{
       
        NSLog(@"1%@", [NSThread currentThread]);
        
    });
    dispatch_async(serial, ^{
        
        NSLog(@"2%@", [NSThread currentThread]);
        
    });
    dispatch_async(serial, ^{
        
        NSLog(@"3%@", [NSThread currentThread]);
        
    });
    dispatch_async(serial, ^{
        
        NSLog(@"4%@", [NSThread currentThread]);
        
    });
    // 添加一个同步
    dispatch_sync(serial, ^{
           NSLog(@"%@", [NSThread currentThread]);
        
    });
    
}

- (void)createConcurent {
    dispatch_queue_t serial = dispatch_queue_create("tech.mafeng", DISPATCH_QUEUE_CONCURRENT);
    NSLog(@"%@", [NSThread currentThread]);
    
    dispatch_async(serial, ^{
        NSLog(@"1 开始");
        NSLog(@"1%@", [NSThread currentThread]);
        
    });
    dispatch_async(serial, ^{
        NSLog(@"2 开始");
        NSLog(@"2%@", [NSThread currentThread]);
        
    });
    dispatch_async(serial, ^{
        NSLog(@"3 开始");
        NSLog(@"3%@", [NSThread currentThread]);
        
    });
    dispatch_async(serial, ^{
        NSLog(@"4 开始");
        NSLog(@"4%@", [NSThread currentThread]);
        
    });
    // 添加一个同步
    dispatch_sync(serial, ^{
        NSLog(@"%@", [NSThread currentThread]);
        
    });
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
